<template>
	<view class="content">
		<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="lower">
			<view class="item" v-for="(item, index) in list" :key="index">
				<view class="left">
					<view class="title">
						{{ item.order_no }}
					</view>
					{{ item.create_time }}
				</view>
				<view class="right">
					{{ item.order_amount }}
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				params: {
					page: 1,
					page_size: 10
				},
				total: 0,
				list: []
			}
		},
		onLoad() {
			this.rechargeList()
		},
		methods: {
			rechargeList() {
				let userinfo = uni.getStorageSync('userinfo')
				this.params.token = userinfo.token
				uni.request({
					url: this.configs.webUrl + '/api/recharge/rechargeList',
					data: this.params,
					success: res => {
						console.log(res);
						this.list = this.list.concat(res.data.data.list)
						this.total = res.data.data.count
					}
				})
			},
			lower() {
				if (this.total > this.params.page * this.params.page_size) {
					this.params.page++
					this.rechargeList()
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	view {
		font-size: initial;
	}

	.content {
		padding: 20rpx;

		.scroll-view {
			height: calc(100vh - 40rpx);

			.item {
				margin-bottom: 10rpx;
				background: #fff;
				border-radius: 24rpx;
				padding: 20rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.left {
					.title {
						font-size: 28rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 500;
						color: #000000;
						margin-bottom: 10rpx;
					}

					font-size: 24rpx;
					font-family: PingFang SC,
					PingFang SC;
					font-weight: 400;
					color: #AAAAAA;
				}

				.right {
					font-size: 40rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 600;
					color: #DE2879;
				}
			}
		}
	}
</style>